<script src="<?php echo URL::base() ?>media/vendor/js/jquery-1.10.2.js"></script>
<script src="<?php echo URL::base() ?>media/js/jquery-1.10.1.min.js"></script>
<link rel="stylesheet" href="<?php echo URL::base() ?>media/vendor/artdialog/skins/default.css" type="text/css"
      media="all"/>
<script src="<?php echo URL::base() ?>media/vendor/artdialog/jquery.artDialog.js"></script>
<script>

    function getData(){
        var puids = $("input[name='puids']").val();
        var ratetype =  document.getElementById('ratetype').value;




        return{'puids':puids,'ratetype':ratetype};
    }
$(document).ready(function(){

    $("#subsync").click(function(){
        var data = getData();

        $.post("<?php echo URL::base(true)?>supplier/supactsync/sync", data,
                function(data){
                    var returndata = JSON.parse(data);
                     if(returndata['code']==200){
                         alert("修改成功"+"\n"
                                +"修改采购单"+returndata['success']['ponum']+"个\n"
                                +"供应商付款单："+returndata['success']['pusunum']+"个");
                     }else if(returndata['code']!=200){
                        alert(returndata['errormsg']);
                        return ;
                    }
            }
        );
    });

    $("input[name='puids']").blur(function() {
            //向后台获取 采购单信息  供应商信息
            var puids = $("input[name='puids']").val();
            if(puids!=''){
                $.get("<?php echo URL::base(true)?>supplier/supactsync/getPurchaseMsg?puids="+puids,
                    function (data) {
                        var returndata = JSON.parse(data);
                        if(returndata['code'] == 200){
                            //把信息现实出来
                            art.dialog({
                                title:"采购单及供应商信息",
                                lock:true,
                                content:returndata['view']
                            });
                        }else{
                            alert(returndata['errormsg']);
                            return ;
                        }
                });
            }
        }
    );


})
    
    
    
    
</script>
<div style="border: 1px">
    <form action="<?php echo URL::base()?>supplier/supactsync/sync">
        <input type="text" name="puids" value="输入采购单号" style="width: 400px">
        <br>
        <br>

        <label style="color: #ff0000">人民币账户更改为外币账户时必须选定汇率类型 </label>
        <select class="select" id="ratetype" style="width: 100px">
            <option value="">汇率类型</option>
            <option value="10">卖出价</option>
            <option value="20">中间价</option>
            <option value="30">自定义</option>
        </select>

        <input class="btn btn-danger" type="button"  id="subsync" value="同步" >
    </form>
</div>
